import logging.handlers, os
def logconfig():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    sh = logging.StreamHandler()

    logger.addHandler(sh)

    logpath = "./log" + os.sep + "aolai.log"
    # 设置时间文件处理器
    trfh = logging.handlers.TimedRotatingFileHandler(logpath, when="midnight", interval=1, backupCount=7, encoding="utf-8")
    # trfh.setLevel(logging.DEBUG)
    logger.addHandler(trfh)

    fm = "%(asctime)s-%(levelname)s-[%(filename)s-%(funcName)s()-%(lineno)d]-%(message)s"
    formatter = logging.Formatter(fm)
    trfh.setFormatter(formatter)
    sh.setFormatter(formatter)


